<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of actualite_m
 *
 * @author Gidaff_02
 */
class Actualite_m extends Model {

    function Actualite_m() {
        parent::Model();
        $this->load->database();
    }

    function get_all_news($per_page, $off_set) {
        $this->db->select();
        $this->db->from('lehu_actualite');
        $this->db->limit($per_page, $off_set);
        $query = $this->db->get();
        return $query->result_array();
    }

    function add_news($data) {
        return $this->db->insert('lehu_actualite', $data);
    }

    function get_news_by_id($id) {
        $query = $this->db->get_where('lehu_actualite', array('id' => $id));
        return $query;
    }

    function update_news($data, $id) {
        return $this->db->update('lehu_actualite', $data, array('id' => $id));
    }

    function delete_news($id) {
        return $this->db->delete('lehu_actualite', array('id' => $id));
    }
    function get_top_news(){
        $this->db->select();
        $this->db->from('lehu_actualite');
        $this->db->order_by('posted_time','DESC');
        $this->db->limit(6);
        $query = $this->db->get();
        return $query->result_array();
    }
}

?>
